package com.zhb.cloud.mapper;

import java.util.List;
import java.util.Optional;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.zhb.cloud.model.UserInfo;
import com.zhb.cloud.model.UserInfoExample;

public interface UserInfoMapper extends GeneralMapper<UserInfo> {
	/**
	 * @MethodName: selectByPhone
	 * @Description: 根据手机号查询
	 * @Author: zhb1316783262@163.com
	 * @param phone
	 * @return Optional<User>
	 * @Date: 2019年4月17日下午4:49:22
	 */
	@Select("select * from user where phone = #{phone}")
	Optional<UserInfo> findByPhone(@Param("phone") String phone);

	/**
	 * @Description: 根据条件统计
	 * @Author: zhb1316783262@qq.com
	 * @Date: 2019-02-21 02:56:01
	 */
	int countByExample(UserInfoExample example);

	/**
	 * @Description: 根据条件删除
	 * @Author: zhb1316783262@qq.com
	 * @Date: 2019-02-21 02:56:01
	 */
	int deleteByExample(UserInfoExample example);
	/**
	 * @Description: 根据条件查询(非分页)
	 * @Author: zhb1316783262@qq.com
	 * @Date: 2019-02-21 02:56:01
	 */
	List<UserInfo> selectByExample(UserInfoExample example);

	/**
	 * @Description: 根据条件更新(动态更新)
	 * @Author: zhb1316783262@qq.com
	 * @Date: 2019-02-21 02:56:01
	 */
	int updateByExampleSelective(@Param("record") UserInfo record, @Param("example") UserInfoExample example);
	/***
	 * @methodName: findAll
	 * @date: 2019/3/27 10:51
	 * @description: 查询所有
	 * @param: []
	 * @return: java.util.List<com.alibaba.cloud.model.UserInfo>
	 * @author: zhb1316783262@163.com
	 **/
	@Select("select id, user_name, password, email, phone, real_name, register_time, gender, address from p_user_info where id<2001")
	List<UserInfo> findAll();

	/**
	 * @MethodName: findByUserName
	 * @Description: 根据用户名查找
	 * @Author: zhb1316783262@163.com
	 * @param userName
	 * @return Optional<UserInfo>
	 * @Date: 2019年4月17日下午5:13:37
	 */
	@Select("select id, user_name, password, email, phone, real_name, register_time, gender, address from p_user_info where user_name=#{userName}")
	Optional<UserInfo> findByUserName(String userName);
}